#include "SYSTEM/delay/delay.h"
#include "SYSTEM/sys/sys.h"
#include "SYSTEM/usart/usart.h"
#include "BSP/LED/led.h"
#include "BSP/BEEP/beep.h"
#include "BSP/KEY/key.h"
#include "BSP/EXTI/exti.h"
#include "BSP/IWDG/wdg.h"
#include "BSP/GTIMER/gtimer.h"
#include "BSP/LCD/lcd.h"
#include "BSP/RTC/rtc.h"

int main()
{
	char* weekdays[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saterday"};
	char information[40];
	
	HAL_Init();
	sys_stm32_clock_init(RCC_PLL_MUL9);
	delay_init(72);
	usart_init(115200);
	led_init();
	lcd_init();
	rtc_init();
	
	rtc_set_alarm(2024, 1, 1, 12, 1, 0);
	
	lcd_show_string(30, 50, 200, 32, 32, "STM32", RED);
	lcd_show_string(30, 90, 200, 32, 32, "RTC_TEST", RED);
	
	while (1)
	{
		rtc_get_time();
		sprintf(information, "Time:%02d:%02d:%02d", calendar.hour, calendar.min, calendar.sec);
		lcd_show_string(30, 130, 300, 32, 32, information, RED);
		sprintf(information, "Date:%02d-%02d-%02d", calendar.year, calendar.month, calendar.date);
		lcd_show_string(30, 170, 300, 32, 32, information, RED);
		sprintf(information, "Week:%s", weekdays[calendar.week]);
		lcd_show_string(30, 210, 300, 32, 32, information, RED);
		delay_ms(50);
	}
}
